var express = require('express');
var NewsRouter = express.Router();


// 图片上传
const multer = require('multer');
const NewsController = require('../../controllers/admin/NewsController');
const upload = multer({ dest: 'public/newsuploads/' })
// 添加新闻
NewsRouter.post("/adminapi/news/add", upload.single('file'), NewsController.add)
// 查询所有新闻
NewsRouter.get("/adminapi/news/list/author/:author", NewsController.getListByAuthor)
// 根据id查询新闻
NewsRouter.get("/adminapi/news/list/id/:id", NewsController.getListById)
// 更新发布状态
NewsRouter.put("/adminapi/news/publish", NewsController.publish)
// 更新新闻
NewsRouter.post("/adminapi/news/update", upload.single('file'), NewsController.update)
// 删除新闻
NewsRouter.delete("/adminapi/news/list/:id", NewsController.delete)

module.exports = NewsRouter;

